package com.relax.paozi;

import java.util.concurrent.locks.Lock;

public class Seller implements Runnable {
    Lock lock;

    private BaoZi baoZi;

    public Seller(Lock lock, BaoZi baoZi) {
        this.lock = lock;
        this.baoZi = baoZi;
    }

    public void run() {

        while (true) {
            synchronized (baoZi) {
                if (baoZi.flag == true) {
                    try {
                        baoZi.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }


                System.out.println("包子铺开始生产包子" + baoZi);
                baoZi.flag = true;
                baoZi.notify();
            }

        }


    }
}
